﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RapidTestMapMaker
{
    public partial class PalleteSwatchUserControl : UserControl
    {
        public PalleteSwatchUserControl()
        {
            InitializeComponent();
        }

        private char keyboardShortcut;
        public char KeyboardShortcut
        {
            get { return keyboardShortcut; }
            set
            {
                keyboardShortcut = value;
                label1.Text = "" + value;
            }
        }

        public TileSet TileSet { get; set; }

        private Tile tile;
        public Tile Tile
        {
            get { return tile; }
            set
            {
                tile = value;
                if (value != null)
                { pictureBox1.Image = value.FullImage; }
                else
                { pictureBox1.Image = null; }
            }
        }

        private void changeTileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                using (OpenFileDialog ofd = new OpenFileDialog() { Title = "Select Tile Image", Filter = "Images|*.jpg;*.png;*.bmp|All Files|*.*" })
                {
                    if (ofd.ShowDialog() == DialogResult.OK)
                    {
                        tile.FullImage = Bitmap.FromFile(ofd.FileName);
                        TileSet.ActiveTile = tile;
                    }
                }
            }
            catch { }
        }

        private void PalleteSwatchUserControl_Click(object sender, EventArgs e)
        {
            TileSet.ActiveTile = Tile;
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            TileSet.ActiveTile = Tile;
        }
    }
}
